<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>联盟云商圈</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" type="text/css" href="../css/style.css"/>
		<link rel="stylesheet" href="../css/iconfont.css" />
		<link rel="stylesheet" href="../css/wallet.css" />
		<link rel="stylesheet" href="../css/style.css" />
		<link rel="stylesheet" href="../css/iconfont.css" />
		<link rel="stylesheet" href="../css/sjhout.css" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left" href="JavaScript:history.go(-1)"></a>
		    <h1 class="mui-title">我的商圈</h1>
		    <a href="javascript:;" class="mui-pull-right add" >创建</a>
		</header>
		<div class="mui-content fjysq_content">
			<div class="fjysq_lisbox">
				<ul class="shop_list">
		
				</ul>
				<button type="button" class="fjysq_btn" style="display: none;" id='crete_union'>创建联盟</button>
				<button type="button" class="fjysq_btn" style="display: none;" id='my_union'>我的联盟</button>
			</div>
		</div>
	</body>
</html>
<script type="text/javascript" src="../js/jquery.min.js"></script>
<script type="text/javascript" src="../js/layer/layer.min.js"></script>
<script type="text/javascript" src="../js/bootstrap.min.js"></script>
<script type="text/javascript" src="../js/app.js"></script>
<script>
	var member = checkLogin(APP.web_root+"member/login.html");
	$(function(){
		$.ajax({
			url: APP.api_url + 'agent/user_union_list',
			data: {
				token: get_token(),
				uid: getUid()
			},
			success: function(data) {
				if(data.code == 200) {
					//检查当前店铺是否联盟成员
					var union_list= data.data;
					var agent_id = union_list[0].agent_id;
					for(var i =0 ;i<union_list.length;i++){
						var pic = user_tupian(union_list[i].un_logo,'../images/toux.jpg');
						union_htm ="<li><a href='fujinysq_show.html?union_id="+union_list[i].un_id+"'>"+
										"<div class='shop_info clearfix'>"+
											"<div class='shop_toux'><img src='"+ pic +"' id='union_logo'></div>"+
											"<div class='shop_nam'>"+union_list[i].un_name+"</div>"+
										"</div>"+
										"<div class='shop_fw clearfix'>"+
											"<div class='left'>"+union_list[i].un_scope+"</div>"+
											"<div class='right'>"+union_list[i].un_store_name+"</div>"+
										"</div>"+
			
									"</a></li>";
						$('.shop_list').append(union_htm);
					}
				}else{
					$('#crete_union').show();
					//layer.msg(data.msg);
				}
			}
		});
		//检查用户是否创建联盟
		$('.add').click(function(){
			$.ajax({
				url: APP.api_url + 'agent/user_union_main',
				data: {
					token: get_token(),
					uid: getUid()
				},
				success: function(data) {
					if(data.code == 201) {//用户为联盟主
						layer.msg('抱歉，暂不支持创建多个联盟');
					}else{	//可创建联盟
						location.href = APP.web_root+'shopwallet/fujinysq_edit.html';
					}
				}
			});	
			
		})
		
		
		$('#crete_union').click(function(){
			location.href = APP.web_root+'shopwallet/fujinysq_edit.html';
		})
		
		$('#my_union').click(function(){
			location.href = APP.web_root+'shopwallet/fujinysq_edit.html';
		})
	})
</script>
